<template>
    <div>
        <!-- seach区域 -->
        <div class="seach">
            <span class="span-top">
                <span class="seachStatus">
                    {{$t('resconiliationdate')}}
                    <el-date-picker :placeholder="$t('plsset')" v-model="billdate" width="20%" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" size="mini"></el-date-picker>
                </span>
                <!-- <span class="seachStatus">
                    {{$t('subttim')}}
                    <el-date-picker :placeholder="$t('plsset')" v-model="recdate" width="20%" type="daterange" :range-separator="$t('to')" :start-placeholder="$t('startdate')" :end-placeholder="$t('dateclosed')" format="yyyy-MM-dd" value-format="yyyy-MM-dd" size="mini"></el-date-picker>
                </span> -->
                <!-- <span class="seachCSC">
                    {{$t('datasources')}}
                    <el-select v-model="cpequform.source" :placeholder="$t('plsset')" size="mini" style="width: 100px">
                        <el-option :label="$t('alltypes')" :value="-1"></el-option>
                        <el-option :label="$t('daydata')" :value="1"></el-option>
                        <el-option :label="$t('bufferpool')" :value="2"></el-option>
                    </el-select>
                </span> -->
            </span>
            <div class="NOUS">
                <el-button type="primary" @click="seach" size="mini" v-preventReClick>{{$t('qury')}}</el-button>
            </div>
        </div>
        <!-- 内容区域 -->
        <el-card class="cardBox">
            <el-table border style="width: 100%" :data="cpequtab">
                <el-table-column type="index" :label="$t('sernum')">
                </el-table-column>
                <el-table-column prop="billingDate" :label="$t('resconiliationdate')">
                </el-table-column>
                <el-table-column prop="flowno" :label="$t('platformserialnum')">
                </el-table-column>
                <el-table-column prop="platCode" :label="$t('platformcode')">
                </el-table-column>
                <el-table-column prop="channelCode" :label="$t('chnnumber')">
                </el-table-column>
                <el-table-column prop="tradeAmount" :label="$t('orderamt')">
                </el-table-column>
            </el-table>
            <!-- 分页 -->
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="cpequform.pageNum"
                :page-sizes="[10, 15, 20, 30]"
                :page-size="cpequform.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </el-card>
    </div>
</template>

<script>
import {
    getcpequalitylist
} from '@/libs/reqlist.js'
import { getInitDate } from '@/libs/getDate.js'
export default {
    data () {
        return {
            total: 0,
            recdate: [],
            billdate: null,
            cpequform: {
                billingDate: null,
                insertTimeStart: null,
                insertTimeEnd: null,
                source: null,
                pageSize: 10,
                pageNum: 1
            },
            cpequtab: []
        }
    },
    methods: {
        seach () {
            // 提交时间查询及展示
            // if (this.recdate !== null) {
            //     this.cpequform.insertTimeStart = this.recdate[0] + ' 00:00:00'
            //     this.cpequform.insertTimeEnd = this.recdate[1] + ' 00:00:00'
            // }
            // if (this.recdate === null) {
            //     this.recdate = []
            //     this.cpequform.insertTimeStart = getInitDate(7) + ' 00:00:00'
            //     this.cpequform.insertTimeEnd = getInitDate(0) + ' 00:00:00'
            //     this.recdate.push(this.cpequform.insertTimeStart)
            //     this.recdate.push(this.cpequform.insertTimeEnd)
            // }
            // 对账日期查询及展示
            if (this.billdate !== null) {
                this.cpequform.billingDate = this.billdate.split('-').join('')
            }
            if (this.billdate === null) {
                this.cpequform.billingDate = null
                this.billdate = null
            }
            this.cpequform.pageNum = 1
            this.getCpEquList()
        },
        getCpEquList () {
            getcpequalitylist(this.cpequform).then(res => {
                if (res.data.code === '000000') {
                    for (let i = 0; i <= res.data.data.list.length - 1; i++) {
                        let item = res.data.data.list[i]
                        item.billingDate = item.billingDate.slice(0, 4) + '-' + item.billingDate.slice(4, 6) + '-' + item.billingDate.slice(6, 8)
                    }
                    this.cpequtab = res.data.data.list
                    this.total = res.data.data.total - 0
                } else {
                    this.$message.error(this.$t('sysexception'))
                }
            })
        },
        handleSizeChange (newSize) {
            this.cpequform.pageSize = newSize
            this.getCpEquList()
        },
        // 监听总页数变化
        handleCurrentChange (newNum) {
            this.cpequform.pageNum = newNum
            this.getCpEquList()
        }
    },
    mounted () {
        this.cpequform.billingDate = getInitDate(0, 1).split('-').join('')
        this.billdate = getInitDate(0, 1)
        // this.cpequform.insertTimeStart = getInitDate(7) + ' 00:00:00'
        // this.cpequform.insertTimeEnd = getInitDate(0) + ' 00:00:00'
        // this.recdate.push(this.cpequform.insertTimeStart)
        // this.recdate.push(this.cpequform.insertTimeEnd)
        this.getCpEquList()
    }
}
</script>

<style lang="less" scoped>
@import './horData.less';
</style>
